<template>
	<view class="content">
		<div class="img">
			<image :src="imgs" mode=""></image>
			<button type="primary" size="mini" @click="login()">登录</button>
		</div>
	</view>
</template>

<script>
	import {
		getlogin
	} from '../../utils/api.js'
	export default {
		data() {
			return {
				imgs: ''
			};
		},
		onLoad() {


		},
		methods: {
			login() {
				uni.getUserProfile({
					desc: '获取你的昵称、头像、地区及性别',
					success: (res) => {
						console.log(res, 30);
					this.imgs = res.userInfo.avatarUrl
						uni.login({
							success: (ele) => {
								let obj = {
									appid: 'wx7708bfcd646a5959',
									secret: '61020ced50667b03d406de0c2726038b',
									nickName: res.userInfo.nickName,
									avatarUrl: res.userInfo.avatarUrl,
									code: ele.code
								}

								getlogin(obj).then(res2 => {
									console.log(res2, 44);
									let token = res2.data.data.user_Token
									uni.setStorageSync('token', res2.data.data)
								})
							}
						})

					}
				})

			}

		}
	}
	
</script>

<style lang="scss">
	.content {
		margin: 0;
		padding: 0;
		box-sizing: border-box;
		width: 750rpx;
		height: 500rpx;
		background-color: #e3efff;

		.img {
			width: 200rpx;
			text-align: center;
			padding-top: 100rpx;
			padding-left: 270rpx;

			image {
				width: 130rpx;
				height: 130rpx;
				border-radius: 50%;
			}

			button {
				letter-spacing: 6rpx;
			}
		}


	}
</style>
